
clear all
set more off
cap log close

ssc install unique
    
global dir "/Replication Archive"
cd "${dir}"

global outreg_settings = " label bdec(4) pvalue pdec(3) tex(frag) excel  nor2 nonotes "


************************************
************* FIGURE 2 *************
************************************

* ENTRY

use "${dir}/Data/Final Datasets/Final_Data_Director_MC_Level_DEF2_EventStudyAppointment_CompanyLevel_HouseSenate_2.dta", clear

egen double Director_Company_MC_event=group(DirectorID CompanyID icpsr2 chamber event)
egen double Director_MC=group(DirectorID CompanyID icpsr2)
egen double Period_MC_event=group(period chamber event icpsr2)

replace donated=donated*1000

reghdfe donated treated_p1 treated_p2 treated_p4, absorb(Director_Company_MC_event Period_MC_event) cluster(Director_MC) compact keepsingletons

codebook DirectorID if e(sample)==1
codebook icpsr2 if e(sample)==1

				foreach x in 1 2 4 {
                local b`x' = _b[treated_p`x']
                local ub_b`x' = _b[treated_p`x'] + 1.96*_se[treated_p`x']
                local lb_b`x' = _b[treated_p`x'] - 1.96*_se[treated_p`x']
                }	

        clear
        set obs 4
        egen t = seq()
        gen b = 0
        gen ub_b = 0
        gen lb_b = 0
		
		label var b "Estimates and 95% Confidence Interval"
		
        foreach x in 1 2 4 {
                replace b = `b`x'' in `x'
                replace ub_b = `ub_b`x'' in `x'
                replace lb_b = `lb_b`x'' in `x'
                }
				
        replace t=t-4
		
		twoway (connect b t, mcolor(grayscale5) lcolor(grayscale5) lpattern(solid) msymbol(O) lwidth(medthick)) ///
				(rcap lb_b ub_b t, lcolor(grayscale5) msymbol(none) lpattern(solid) lwidth(medthick)), ///
				xtitle("") xlabel(-3(1)0, labsize(small) grid) ///
                ylabel(-0.00005(0.00005)0.0004, labsize(small) angle(0) glcolor(gs16) grid) ///
                legend(off) ///
				yline(0, lcolor(black) lpattern(solid)) 
				graph export "${dir}/Results/Figure_2_A", as(pdf) replace
				graph save "${dir}/Results/Figure_2_A", replace

				
* EXIT

use "${dir}/Data/Final Datasets/Final_Data_Director_MC_Level_DEF2_EventStudyExit_CompanyLevel_HouseSenate_2.dta", clear

egen double Director_Company_MC_event=group(DirectorID CompanyID chamber icpsr2 event)
egen double Director_MC=group(DirectorID icpsr2)
egen double Period_event=group(period chamber event)
egen double Period_MC_event=group(period event chamber icpsr2)

replace donated=donated*1000

reghdfe donated treated_p1 treated_p2 treated_p4, absorb(Director_Company_MC_event Period_MC_event) cluster(Director_MC) compact keepsingletons

codebook DirectorID if e(sample)==1
codebook icpsr2 if e(sample)==1

				foreach x in 1 2 4 {
                local b`x' = _b[treated_p`x']
                local ub_b`x' = _b[treated_p`x'] + 1.96*_se[treated_p`x']
                local lb_b`x' = _b[treated_p`x'] - 1.96*_se[treated_p`x']
                }	

        clear
        set obs 4
        egen t = seq()
        gen b = 0
        gen ub_b = 0
        gen lb_b = 0
		
		label var b "Estimates and 95% Confidence Interval"
		
        foreach x in 1 2 4 {
                replace b = `b`x'' in `x'
                replace ub_b = `ub_b`x'' in `x'
                replace lb_b = `lb_b`x'' in `x'
                }
				
        replace t=t-4
		
		twoway (connect b t, mcolor(grayscale5) lcolor(grayscale5) lpattern(solid) msymbol(O) lwidth(medthick)) ///
				(rcap lb_b ub_b t, lcolor(grayscale5) msymbol(none) lpattern(solid) lwidth(medthick)), ///
				xtitle("") xlabel(-3(1)0, labsize(small) grid) ///
                ylabel(#10, labsize(small) angle(0) glcolor(gs16)) ///
                legend(off) ///
				yline(0, lcolor(black) lpattern(solid)) 
				graph export "${dir}/Results/Figure_2_B", as(pdf) replace
				graph save "${dir}/Results/Figure_2_B", replace				
		

